package com.neusoft.neuiotms.dcam.workflow.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.neusoft.bizcore.auth.common.bean.UserBean;
import com.neusoft.bizcore.web.dto.result.ResultDTO;
import com.neusoft.neuiotms.dcam.workflow.dto.TuikuSLDTO;
import com.neusoft.neuiotms.dcam.workflow.service.TuikuSLService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

@Api(tags = "科技公司退库工单")
@RestController
@RequestMapping(value = "/api/w/workflow/tuikusl")
public class TuikuSLController {

    @Autowired
    private TuikuSLService tuikuSLService;

    @ApiOperation("新增资产退库申请")
    @PostMapping
    public ResultDTO<TuikuSLDTO> create(@RequestBody final TuikuSLDTO dto,
            final UserBean user) {
        return ResultDTO.success(this.tuikuSLService.create(dto, user));
    }

    @ApiOperation("查看资产退库申请")
    @GetMapping("/{workOrderNum}/{taskId}")
    public ResultDTO<TuikuSLDTO> details(@PathVariable final String workOrderNum,
            @PathVariable final String taskId,
            final UserBean user) {
        return ResultDTO.success(this.tuikuSLService.detail(workOrderNum, taskId, user));
    }

    @ApiOperation("新增资产退库确认")
    @PostMapping("confirm")
    public ResultDTO<Void> confirmCreate(@RequestBody final TuikuSLDTO dto,
            final UserBean user) {
        this.tuikuSLService.confirmCreate(dto, user);
        return ResultDTO.success();
    }

    @ApiOperation("查看资产退库确认")
    @GetMapping("confirm/{workOrderNum}/{taskId}")
    public ResultDTO<TuikuSLDTO> confirmDetails(@PathVariable final String workOrderNum,
            @PathVariable final String taskId,
            final UserBean user) {
        return ResultDTO.success(this.tuikuSLService.confirmDetails(workOrderNum, taskId, user));
    }
}
